package Tree;

/**
 * 作者:hfj
 * 功能:101.对称二叉树
 * 日期: 2025/10/24 10:13
 */
public class IsSymmetric {
    public boolean isSymmetric(TreeNode root) {
        if (root == null){
            return true;
        }
        return CMP(root.left,root.right);
    }

    public boolean CMP(TreeNode left, TreeNode right) {
        if (left == null && right == null){
            return true;
        }
        if (left == null || right == null){
            return false;
        }
        if (left.val != right.val){
            return false;
        }
        return CMP(left.left,right.right) && CMP(left.right,right.left);
    }
}
